/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CommonProfile;

import Entity.Admin;
import Entity.PersonalInfo;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author WinKiQue58
 */
@Stateless
public class Sign_In implements Sign_InLocal {

     @PersistenceContext(unitName = "S3R4_Orcl-ejbPU")
            private EntityManager em;
     
    public PersonalInfo SignIn_S3R4( String name, String pass )
    {
        PersonalInfo p=null;     
        
        //--Name is Unique restriction!
         Query q1= em.createQuery("SELECT pi FROM PersonalInfo pi WHERE pi.user = :NAME AND pi.pass = :PASS ");
         q1.setParameter("NAME", name);
         q1.setParameter("PASS", pass);
         
         try{
         p= (PersonalInfo) q1.getSingleResult();
         } catch(NoResultException e) {
           return null;
        }
        
         return p;
         
    }
    
}
